var CryptoJS = require("crypto-js")

module.exports = {

	//加密：
	jiami(content, key1) { //需要加密的内容，aes密钥

		var key = CryptoJS.enc.Utf8.parse(key1)
		var plaintText = content

		var encryptedData = CryptoJS.AES.encrypt(plaintText, key, {
			mode: CryptoJS.mode.ECB,
			padding: CryptoJS.pad.Pkcs7
		})
		return encryptedData
	},

	//解密：
	jiemi(decryptString, key) { //需要解密的数据  aes密钥
		var key = CryptoJS.enc.Utf8.parse(key);
		var decrypt = CryptoJS.AES.decrypt(decryptString, key, {
			mode: CryptoJS.mode.ECB,
			padding: CryptoJS.pad.Pkcs7
		});
		return CryptoJS.enc.Utf8.stringify(decrypt).toString();
	}

}